
#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int n = 0, a = 0, b = 0;
	cin >> n >> a >> b;
	int jg = 2 * n - 1;
	int linea = 0, lineb = 0, i = 0;
	///a
	int sum = n;
	while (a > sum)
	{
		i++;
		sum = i * n;
	}
	int higha = sum / n;
	///b
	sum = n;
	i = 0;
	while (b > sum)
	{
		i++;
		sum = i * n;
	}
	int highb = sum / n;
	/////a
	if (higha % 2 == 1)
	{
		linea = n - (higha * n - a);
	}
	else
	{
		linea = higha * n - a + 1;
	}
	/////b
	if (highb % 2 == 1)
	{
		lineb = n - (highb * n - b);
	}
	else
	{
		lineb = highb * n - b + 1;
	}

	int m = abs(linea - lineb) + abs(higha - highb);
	cout << m;


	return 0;
}